﻿#ifndef TCPTHREAD_H
#define TCPTHREAD_H

#include <QThread>
#include <QTcpSocket>
#include <ctime>
#include <QtCore/QTimer>

class TCPThread: public QThread
{
    Q_OBJECT
public:
    TCPThread(uint _id, int _ip);
    ~TCPThread();

    int IP() const {return ip;}
    uint ID() const {return id;}

protected:
    virtual void run() override;

signals:
    void sig_dtuUpdate(uint id, const QList<int>& data);
    void sig_dtuUpload(uint id, const QList<int>& data);

private slots:
    void slt_handleTimeout();
    void slt_readData();

private:
    QByteArray cmdSend;
    QTimer* m_timer;
    clock_t begin,end;
    QTcpSocket* tcpSocket;
    int ip;
    uint id;
    int cnt_line = 0;
};

#endif // TCPTHREAD_H
